import request from '@/utils/request'
import store from '@/store'

// 用户-登陆
export const loginAPI = ({ mobile, code }) => {
  return request({
    url: '/v1_0/authorizations',
    method: 'POST',
    data: {
      mobile: mobile,
      code: code
    }
  })
}
// 用户-更新token
export const refreshTokenAPI = () => {
  return request({
    url: '/v1_0/authorizations',
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${store.state.refresh_token}`
    }
  })
}

// 用户-基本资料
export const userInfoAPI = () => {
  return request({
    url: '/v1_0/user'
  })
}

// 用户-个人资料
export const profileAPI = () => {
  return request({
    url: '/v1_0/user/profile'
  })
}

// 用户-更新头像
export const photoAPI = (fromDate) => {
  return request({
    url: '/v1_0/user/photo',
    method: 'PATCH',
    data: fromDate

  })
}
// 用户-更新资料
export const updateProfileAPI = ({ birthday, newname }) => {
  return request({
    url: '/v1_0/user/profile',
    method: 'PATCH',
    data: {
      birthday,
      name: newname

    }
  })
}
